package com.yanqu.road.entity.activity.dunhuangshiku;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.player.UserBaseInfo;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description 敦煌石窟玩家对象
 * @Author cwq
 * @Data 2021/4/15 18:14
 */
@FieldTypeAnnotation(tableName = "t_c_dunhuangshiku_user_data")
public class DunHuangShiKuUserData extends DataObject {
    @FieldTypeAnnotation(select = true, update = true)
    private long activityId;
    @FieldTypeAnnotation(select = true, update = true, desc = "分组ID")
    private int groupId;
    @FieldTypeAnnotation(update = true, desc = "玩家所在区服")
    private long serverId;
    @FieldTypeAnnotation(update = true)
    private long userId;
    @FieldTypeAnnotation(desc = "当前所在区域")
    private int regionId;
    @FieldTypeAnnotation(desc = "已解锁到的区域")
    private int unlockRegionId;
    @FieldTypeAnnotation(desc = "体力")
    private int energy ;
    @FieldTypeAnnotation(desc = "上次使用体力的时间")
    private long energyLastTime ;
    @FieldTypeAnnotation(desc = "总血量,该值仅在莫高窟区域产生作用")
    private long blood ;
    @FieldTypeAnnotation(desc = "剩余血量")
    private long remainBlood ;
    @FieldTypeAnnotation(desc = "攻击力,该值在玩家每次进入活动时,都会更新为最新状态")
    private long attack ;
    @FieldTypeAnnotation(desc = "玩家最后一次进入活动的门客总赚钱值 （计算npc血量用）")
    private long earn ;
    @FieldTypeAnnotation(desc = "玩家最后一次进入活动的门客总赚钱值 （查看队伍详情用）")
    private long curPatronsEarn ;
    @FieldTypeAnnotation(desc = "当前遇到的事件Id")
    private int eventId;
    @FieldTypeAnnotation(desc = "目标id/血量 如果事件是玩家事件该值代表目标id，npc事件代表npc血量")
    private long targetId;
    @FieldTypeAnnotation(desc = "遇到目标的总血量")
    private long targetTotalBlood;
    @FieldTypeAnnotation(desc = "攻击状态 0未攻击 1已攻击未被标记 2已标记")
    private int attackStatus;
    @FieldTypeAnnotation(desc = "上次攻击时间(npc事件、玩家战斗事件才有)")
    private long lastAttackTime ;
    @FieldTypeAnnotation(desc = "所在队伍id,没有则为0")
    private int teamId;
    @FieldTypeAnnotation(desc = "玩家活动的总积分")
    private long allScore;
    @FieldTypeAnnotation(desc = "玩家珍贵文书数量")
    private int bookNum;
    @FieldTypeAnnotation(desc = "玩家主动离开上一个队伍的时间,被踢出队伍不记录时间")
    private long lastTimeLeaveTime;
    @FieldTypeAnnotation(desc = "玩家上次创建队伍的时间")
    private long lastTimeCreateTime;
    @FieldTypeAnnotation(desc = "当前领取到的壁画id位")
    private long muralBit;
    @FieldTypeAnnotation(desc = "入队后是否进入过活动")
    private boolean isEnter;
    @FieldTypeAnnotation(desc = "已杀的人数")
    private int curKillNum;
    @FieldTypeAnnotation(desc = "已经抢夺的文书数量")
    private int curRobBookNum;
    @FieldTypeAnnotation(desc = "离队信息")
    private DunHuangShiKuLeaveInfo leaveInfo;
    @FieldTypeAnnotation(desc = "仇人信息")
    private DunHuangShiKuEnemyInfo enemyInfo;
    @FieldTypeAnnotation(desc = "仇人集合<仇人id,击杀我次数>")
    private Map<Long,Integer> enemyInfoMap = new HashMap<>();
    @FieldTypeAnnotation(desc = "申请加入的联盟 k:联盟id v:申请时间")
    private Map<Integer, Long> applyJoinTeamMap = new HashMap<>();
    @FieldTypeAnnotation(desc = "宝箱事件剩余数量")
    private Map<Integer, Integer> boxMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "完成事件的数量集合")
    private Map<Integer, Integer> finishEventMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "用户基本信息")
    private UserBaseInfo userBaseInfo = new UserBaseInfo();
    private Map<Integer, Integer> allEventNumMap = new ConcurrentHashMap<>();

    private int helpTimes;
    @FieldTypeAnnotation(desc = "体力")
    private int consumeEnergy ;

    public DunHuangShiKuUserData() {}

    public DunHuangShiKuUserData(int activityId, int groupId, long userId) {
        this.activityId = activityId;
        this.groupId = groupId;
        this.userId = userId;
        setInsertOption();
    }

    public void setActivityId(long activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }

    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public void setServerId(long serverId) {
        if (this.serverId != serverId) {
            this.serverId = serverId;
            setOp(DataStatus.Update);
        }

    }
    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }

    }
    public void setRegionId(int regionId) {
        if (this.regionId != regionId) {
            this.regionId = regionId;
            setOp(DataStatus.Update);
        }

    }
    public void setUnlockRegionId(int unlockRegionId) {
        if (this.unlockRegionId != unlockRegionId) {
            this.unlockRegionId = unlockRegionId;
            setOp(DataStatus.Update);
        }
    }
    public void setEnergy(int energy) {
        if (this.energy != energy) {
            this.energy = energy;
            setOp(DataStatus.Update);
        }

    }
    public void setEnergyLastTime(long energyLastTime) {
        if (this.energyLastTime != energyLastTime) {
            this.energyLastTime = energyLastTime;
            setOp(DataStatus.Update);
        }

    }
    public void setBlood(long blood) {
        if (this.blood != blood) {
            this.blood = blood;
            setOp(DataStatus.Update);
        }

    }
    public void setRemainBlood(long remainBlood) {
        if (this.remainBlood != remainBlood) {
            this.remainBlood = remainBlood;
            setOp(DataStatus.Update);
        }

    }
    public void setAttack(long attack) {
        if (this.attack != attack) {
            this.attack = attack;
            setOp(DataStatus.Update);
        }

    }
    public void setEarn(long earn) {
        if (this.earn != earn) {
            this.earn = earn;
            setOp(DataStatus.Update);
        }

    }

    public void setCurPatronsEarn(long curPatronsEarn) {
        if (this.curPatronsEarn != curPatronsEarn) {
            this.curPatronsEarn = curPatronsEarn;
            setOp(DataStatus.Update);
        }

    }


    public void setEventId(int eventId) {
        if (this.eventId != eventId) {
            this.eventId = eventId;
            setOp(DataStatus.Update);
        }

    }
    public void setTargetId(long targetId) {
        if (this.targetId != targetId) {
            this.targetId = targetId;
            setOp(DataStatus.Update);
        }

    }

    public void setTargetTotalBlood(long targetTotalBlood) {
        if (this.targetTotalBlood != targetTotalBlood) {
            this.targetTotalBlood = targetTotalBlood;
            setOp(DataStatus.Update);
        }

    }
    public void setAttackStatus(int attackStatus) {
        if (this.attackStatus != attackStatus) {
            this.attackStatus = attackStatus;
            setOp(DataStatus.Update);
        }

    }
    public void setLastAttackTime(long lastAttackTime) {
        if (this.lastAttackTime != lastAttackTime) {
            this.lastAttackTime = lastAttackTime;
            setOp(DataStatus.Update);
        }

    }
    public void setTeamId(int teamId) {
        if (this.teamId != teamId) {
            this.teamId = teamId;
            setOp(DataStatus.Update);
        }

    }
    public void setAllScore(long allScore) {
        if (this.allScore != allScore) {
            this.allScore = allScore;
            setOp(DataStatus.Update);
        }

    }
    public void setBookNum(int bookNum) {
        if (this.bookNum != bookNum) {
            this.bookNum = bookNum;
            setOp(DataStatus.Update);
        }

    }
    public void setLastTimeLeaveTime(long lastTimeLeaveTime) {
        if (this.lastTimeLeaveTime != lastTimeLeaveTime) {
            this.lastTimeLeaveTime = lastTimeLeaveTime;
            setOp(DataStatus.Update);
        }

    }
    public void setLastTimeCreateTime(long lastTimeCreateTime) {
        if (this.lastTimeCreateTime != lastTimeCreateTime) {
            this.lastTimeCreateTime = lastTimeCreateTime;
            setOp(DataStatus.Update);
        }

    }
    public void setMuralBit(long muralBit) {
        if (this.muralBit != muralBit) {
            this.muralBit = muralBit;
            setOp(DataStatus.Update);
        }

    }

    public void setIsEnter(boolean isEnter) {
        if (this.isEnter != isEnter) {
            this.isEnter = isEnter;
            setOp(DataStatus.Update);
        }

    }

    public void setCurKillNum(int curKillNum) {
        if (this.curKillNum != curKillNum) {
            this.curKillNum = curKillNum;
            setOp(DataStatus.Update);
        }

    }

    public void setCurRobBookNum(int curRobBookNum) {
        if (this.curRobBookNum != curRobBookNum) {
            this.curRobBookNum = curRobBookNum;
            setOp(DataStatus.Update);
        }

    }

    public void setLeaveInfo(DunHuangShiKuLeaveInfo leaveInfo) {
        if (!JSON.toJSONString(this.leaveInfo).equals(JSON.toJSONString(leaveInfo))) {
            this.leaveInfo = leaveInfo;
            setOp(DataStatus.Update);
        }
    }


    public void setEnemyInfo(DunHuangShiKuEnemyInfo enemyInfo) {
        if (!JSON.toJSONString(this.enemyInfo).equals(JSON.toJSONString(enemyInfo))) {
            this.enemyInfo = enemyInfo;
            setOp(DataStatus.Update);
        }
    }

    public void setUserBaseInfo(UserBaseInfo userBaseInfo) {
        if (!JSON.toJSONString(this.userBaseInfo).equals(JSON.toJSONString(userBaseInfo))) {
            this.userBaseInfo = userBaseInfo;
            setUpdateOption();
        }
    }

    public long getActivityId() {
        return activityId;
    }

    public int getGroupId() {
        return groupId;
    }

    public long getServerId() {
        return serverId;
    }

    public long getUserId() {
        return userId;
    }

    public int getRegionId() {
        return regionId;
    }

    public int getUnlockRegionId() {
        return unlockRegionId;
    }

    public int getEnergy() {
        return energy;
    }

    public long getEnergyLastTime() {
        return energyLastTime;
    }

    public long getBlood() {
        return blood;
    }

    public long getRemainBlood() {
        return remainBlood;
    }

    public long getAttack() {
        return attack;
    }

    public int getEventId() {
        return eventId;
    }

    public long getTargetId() {
        return targetId;
    }

    public int getAttackStatus() {
        return attackStatus;
    }

    public long getLastAttackTime() {
        return lastAttackTime;
    }

    public int getTeamId() {
        return teamId;
    }

    public long getAllScore() {
        return allScore;
    }

    public int getBookNum() {
        return bookNum;
    }

    public long getLastTimeLeaveTime() {
        return lastTimeLeaveTime;
    }

    public long getLastTimeCreateTime() {
        return lastTimeCreateTime;
    }

    public long getMuralBit() {
        return muralBit;
    }

    public int getCurKillNum() {
        return curKillNum;
    }

    public DunHuangShiKuLeaveInfo getLeaveInfo() {
        return leaveInfo;
    }

    public DunHuangShiKuEnemyInfo getEnemyInfo() {
        return enemyInfo;
    }


    public Map<Long, Integer> getEnemyInfoMap() {
        return enemyInfoMap;
    }

    public void setEnemyInfoMap(Map<Long, Integer> enemyInfoMap) {
        this.enemyInfoMap = enemyInfoMap;
        setUpdateOption();
    }

    public Map<Integer, Long> getApplyJoinTeamMap() {
        return applyJoinTeamMap;
    }

    public void setApplyJoinTeamMap(Map<Integer, Long> applyJoinTeamMap) {
        this.applyJoinTeamMap = applyJoinTeamMap;
        setUpdateOption();
    }

    public Map<Integer, Integer> getBoxMap() {
        return boxMap;
    }

    public void setBoxMap(Map<Integer, Integer> boxMap) {
        this.boxMap = boxMap;
        setUpdateOption();
    }

    public Map<Integer, Integer> getFinishEventMap() {
        return finishEventMap;
    }

    public void setFinishEventMap(Map<Integer, Integer> finishEventMap) {
        this.finishEventMap = finishEventMap;
        setUpdateOption();
    }

    public UserBaseInfo getUserBaseInfo() {
        return userBaseInfo;
    }

    public boolean isEnter() {
        return isEnter;
    }

    public long getEarn() {
        return earn;
    }

    public int getCurRobBookNum() {
        return curRobBookNum;
    }

    public long getCurPatronsEarn() {
        return curPatronsEarn;
    }

    public long getTargetTotalBlood() {
        return targetTotalBlood;
    }

    public Map<Integer, Integer> getAllEventNumMap() {
        return allEventNumMap;
    }

    public void setAllEventNumMap(Map<Integer, Integer> allEventNumMap) {
        this.allEventNumMap = allEventNumMap;
    }

    public void addEventNum(int eventId) {
        Integer num = allEventNumMap.getOrDefault(eventId, 0);
        allEventNumMap.put(eventId, num + 1);
        setUpdateOption();
    }

    public int getHelpTimes() {
        return helpTimes;
    }

    public void setHelpTimes(int helpTimes) {
        if (!Objects.equals(this.helpTimes, helpTimes)) {
            this.helpTimes = helpTimes;
            setUpdateOption();
        }
    }

    public int getConsumeEnergy() {
        return consumeEnergy;
    }

    public void setConsumeEnergy(int consumeEnergy) {
        if (!Objects.equals(this.consumeEnergy, consumeEnergy)) {
            this.consumeEnergy = consumeEnergy;
            setUpdateOption();
        }
    }
}
